package com.ledim.ledimview;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.ledim.adapter.FiltersAdapter;
import com.ledim.bean.FilterListBean;
import com.ledim.widget.view.NoScrollListView;
import com.ledim.widget.view.TagFilterCallbackListener;
import com.letv.android.young.client.R;
import java.util.ArrayList;

public class FilterTabsView extends LinearLayout {

    private NoScrollListView mListView;
    private Context mContext;
    private FiltersAdapter mFilterAdapter;

    public FilterTabsView(Context context) {
        super(context);
        mContext = context;
    }

    public FilterTabsView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public FilterTabsView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
    }

    //绑定数据
    public void bindData(ArrayList<FilterListBean> filters, TagFilterCallbackListener listener) {
        if (mFilterAdapter == null) {
            mListView = (NoScrollListView) findViewById(R.id.listView_channels);
            mFilterAdapter = new FiltersAdapter(mContext, filters, listener);
            mListView.setAdapter(mFilterAdapter);
        } else {
            mFilterAdapter.setDatas(filters);
            mFilterAdapter.notifyDataSetChanged();
        }
    }

}
